package com.kymatrix.mpo.plus.bpm.server.dao.category;

import com.kymatrix.mpo.plus.bpm.server.config.mybatis.mapper.BaseMapperX;
import com.kymatrix.mpo.plus.bpm.server.config.mybatis.query.LambdaQueryWrapperX;
import com.kymatrix.mpo.plus.bpm.server.model.entity.definition.BpmCategoryEntity;
import com.kymatrix.mpo.plus.bpm.server.model.form.category.PageQueryBpmCategoryReq;
import com.kymatrix.mpo.plus.common.business.common.PageResp;
import java.util.Collection;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;

/**
 * BPM 流程分类 Mapper
 */
@Mapper
public interface BpmCategoryMapper extends BaseMapperX<BpmCategoryEntity> {

    default PageResp<BpmCategoryEntity> selectPage(PageQueryBpmCategoryReq reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmCategoryEntity>()
                .likeIfPresent(BpmCategoryEntity::getName, reqVO.getName())
                .likeIfPresent(BpmCategoryEntity::getCode, reqVO.getCode())
                .eqIfPresent(BpmCategoryEntity::getStatus, reqVO.getStatus())
                .betweenIfPresent(BpmCategoryEntity::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(BpmCategoryEntity::getSort));
    }

    default BpmCategoryEntity selectByName(String name) {
        return selectOne(BpmCategoryEntity::getName, name);
    }

    default BpmCategoryEntity selectByCode(String code) {
        return selectOne(BpmCategoryEntity::getCode, code);
    }

    default List<BpmCategoryEntity> selectListByCode(Collection<String> codes) {
        return selectList(BpmCategoryEntity::getCode, codes);
    }

    default List<BpmCategoryEntity> selectListByStatus(String status) {
        return selectList(BpmCategoryEntity::getStatus, status);
    }

}
